<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备工艺记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>设备编号：</label>
                                <input type="text" name="equipmentId"/>
                            </li>
                            <li>
                                <label>日期：</label>
                                <input type="text" class="time-input" name="maintainDateStart" placeholder="请选择日期" />
                                <span>~</span>
                                <input type="text" class="time-input" name="maintainDateEnd" placeholder="请选择日期" />
                            </li>
                            <li>
                                <label>工艺名称：</label>
                                <input type="text" name="processName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="equipment:processrecord:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="equipment:processrecord:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="equipment:processrecord:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info single disabled" onclick="$.operate.detailTab()" shiro:hasPermission="equipment:processrecord:detail">
                    <i class="fa fa-search"></i> 详细
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="equipment:processrecord:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-success" onclick="addcb()" shiro:hasPermission="equipment:processrecord:addcb">
                    <i class="fa fa-plus"></i> 添加换挡片记录
                </a>
                <a class="btn btn-primary single disabled" onclick="editcb()" shiro:hasPermission="equipment:processrecord:editcb">
                    <i class="fa fa-edit"></i> 修改换挡片记录
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('equipment:processrecord:edit')}]];
        var removeFlag = [[${@permission.hasPermi('equipment:processrecord:remove')}]];
        var prefix = ctx + "equipment/processrecord";

        var columns = [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: '编号',
                visible: false
            },
            {
                field: 'equipmentId',
                title: '设备编号',
                sortable: true
            },
            {
                field: 'maintainDate',
                title: '记录日期',
                sortable: true
            },
            {
                field: 'processName',
                title: '工艺名称',
                sortable: true
            },
            {
                field: 'heatsNumber',
                title: '炉数',
                sortable: true
            },
            {
                field: 'programName',
                title: '程序名',
                sortable: true
            },
            {
                field: 'programRemark',
                title: '程序名备注',
                visible: false
            },
            {
                field: 'operatePerson',
                title: '操作者'
            },
            {
                field: 'accuThickness',
                title: '累计厚度'
            },
            {
                field: 'blankUsedTimes',
                title: '挡片累计使用次数'
            },
            {
                field: 'remark',
                title: '备注',
                formatter: function(value, row, index) {
                    //通过判断单元格的值，来格式化单元格，返回的值即为格式化后包含的元素
                    var a = "";
                    if(value.substring(0, 5) === "已更换挡片") {
                        var a = '<span style="color:#f30303;">'+value+'</span>';
                    } else {
                        var a = '<span>'+value+'</span>';
                    }
                    return a;
                }
            }
        ];

        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            detailUrl: prefix + "/detail/{id}",
            modalName: "设备工艺记录",
            columns: columns
        };

        $(function() {
            $.table.init(options);
        });

        function addcb() {
            var addcbUrl = prefix + "/addcb";
            table.set();
            $.modal.open("新增换挡片记录", addcbUrl);
        }

        function editcb() {
            // 获取当前行
            var row = $("#bootstrap-table").bootstrapTable('getSelections');
            let id = row[0].id;
            if ($.common.isNotEmpty(id)) {
                var editcbUrl = prefix + "/editcb/" + id;
                table.set();
                $.modal.open("修改换挡片记录", editcbUrl);
            }
        }
    </script>
</body>
</html>